TroubleShooting - ARexx error codes

back to section start!
 ARexx errors

  The ARexx interpreter itself is pretty informative with it's error messages
when a script fails, usually you will get an error number and the reason.

  For example, copy the following to a separate file called 'Fail.rexx' and
then execute it from a shell with rx Fail.rexx.

/* Fail.rexx */
say "Hello world!
exit

  If you did that, you'll probably get an error message as below:

+++ Error 5 in line 2: Unmatched quote

  This is pretty self-explanatory, there is a quote missing or extra in
line 2, in this case line 2 needs an extra quote on the end of the line:

say "Hello world!"

  That's enough to fix this script, and allow it to run.

  Sometimes you only get an error number, (although I can't remember the
last time I saw just a number), in that case you can just look up what it
means in the ARexx documentation that was included with OS2.04+ or ARexx 1.15
if you bought it separately.

  If the error has occurred because of an Opus ARexx command, you will get an
error code generated for it but no message indicating what went wrong.

/* Fail2.rexx */
address 'DOPUS.1'
lister query 123456 path
path = result
exit

  The above example, if you copy it to a file and execute it, will generate
an error code such as the one below:

  3 *-* lister query 123456 path;
+++ Command returned 10

  Not very informative is it?  All you know is that it failed with error code
10 at line 3.  However, you can look this up in the Opus manual or the Opus
ARexx AmigaGuide to find out what it really means, and you would get:

invalid lister handle

  Opus also provides the  dopus error  ARexx command that you can use within
your scripts to provide more information.  If you open a shell and type the
following:

rx "address 'DOPUS.1';options results;dopus error 10;say result"

  You'll get the same message text as above.

  So if we also use the ARexx special variable  sigl , (sigl is the line
which caused a transfer of control, in this case the line that caused the
script to jump to the error routine), in the example above, so that it now
looks like:

/* Fail2.rexx */
options results
signal on error
address 'DOPUS.1'
lister query 123456 path
path = result
exit
error:
dopus error rc
say result' in line 'sigl':' sourceline(sigl)

  Now when you run it, instead of just the error code you got above, you'll
get the message:

invalid lister handle in line 5: lister query 123456 path

  More informative to you and to any users of your scripts.

  A list of Opus ARexx error codes can be found  here .

DOpus PLUS - giving you that bit extra...